<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>IFE JavaScript Task 01</title>
  </head>
<body>

  <h3>污染城市列表</h3>
  <ul id="aqi-list">
<!--   
    <li>第一名：福州（样例），10</li>
  	<li>第二名：福州（样例），10</li> -->
  </ul>

<script type="text/javascript">

var aqiData = [
  ["北京", 90],
  ["上海", 50],
  ["福州", 10],
  ["广州", 50],
  ["成都", 90],
  ["西安", 100]
];

(function () {

  /*
  遍历读取aqiData中各个城市的数据
  将空气质量指数大于60的城市显示到aqi-list的列表中
  */
  var aqiList = document.getElementById("aqi-list");
  /*
	定义空数组的几种方式
	var arr = ();
	var arr = [];
	var arr = new Array();
  */
  var subData = new Array();
  for(var i = 0; i < aqiData.length; i++) {
  	if(aqiData[i][1] >= 60) {
  		subData.push(aqiData[i]);
  	}
  }

  subData.sort(function(a, b){ return b[1]-a[1]; });

  /*
  	追求完美！！！
  */
  var number = ["一", "二", "三", "四", "五", "六", "七", "八", "九"];
  
  for(var i=0; i < subData.length; i++) {
  	aqiList.innerHTML += "<li>第" + number[i] + "名：" + subData[i][0] + " , " + subData[i][1] + "</li>";
  }
})();

</script>
</body>
</html>